-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: HLS 세그먼트를 앞부분부터 잘라서 로드시킬 수 있는 커스텀 리소스 로더 구현 #330
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다! 그래도 성능이 좋지 못한 기기에서는 효율적으로 동작하지 않을까 싶어요~ 멋집니다
private func sliceM3U8Playlist(_ m3u8Playlist: String, duration: TimeInterval) -> String { | ||
var duration = duration | ||
var playlist = m3u8Playlist.components(separatedBy: M3U8Tag.extinf.rawValue) | ||
.compactMap { | ||
if $0.contains(M3U8Tag.extm3u.rawValue) { return $0 } // 시작부분 | ||
else if let tsDuration = $0.components(separatedBy: ",").compactMap({ Double($0) }).first, | ||
duration > .zero { | ||
duration -= tsDuration | ||
return $0 | ||
} else { | ||
return nil | ||
} | ||
}.joined(separator: M3U8Tag.extinf.rawValue) | ||
|
||
if !playlist.contains(M3U8Tag.extend.rawValue) { | ||
playlist.append("\n\(M3U8Tag.extend.rawValue)") | ||
} | ||
|
||
return playlist | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
if $0.contains(M3U8Tag.extm3u.rawValue) { return $0 } // 시작부분 | ||
else if let tsDuration = $0.components(separatedBy: ",").compactMap({ Double($0) }).first, | ||
duration > .zero { | ||
duration -= tsDuration | ||
return $0 | ||
} else { | ||
return nil | ||
} | ||
}.joined(separator: M3U8Tag.extinf.rawValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pdf로만 봤었는데 m3u8파일 내부를 까서 시작 부분부터 재생할 duration까지만 ts 세그먼트를 합치는 고런 로직이군요.. 좋습니당
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞아요 간단한...3초 3겹살...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
영상이 많아지면 메모리 개선이 유의미하지 않을까 싶네요!
지도에 적용해보면서 첨부해주신 영상 다시 보겠습니다.. pdf만 봤었는데 영상이 있는줄 몰랐네용,,
수고하셨습니다 !
🧑🚀 PR 요약
네이버 Deview 2021 세션을 참고해서 구현했습니다.
문제가 우리 앱을 실기기 테스트를 해보니 메모리를 평균 27메가 정도로 상당히 적게 먹어서 홈 캐러셀 쪽은 별로 의미가 없는 것 같네요.
나중에 유경님 여유되시면 맵쪽 캐러셀에 적용해보셔서 실험 해보심 어떨까 합니다.
Linked Issue
close #266